package com.csweimei.rentmanagementtreasure.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.base.AppConfig;
import com.csweimei.rentmanagementtreasure.http.entity.TabOne2Bean;
import com.csweimei.rentmanagementtreasure.http.entity.TabOneScheduleBean;
import com.csweimei.rentmanagementtreasure.utils.ValidateUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class TabOneScheduleAdapter extends BaseQuickAdapter<TabOneScheduleBean.DataDTO, BaseViewHolder> {
    public TabOneScheduleAdapter() {
        super(R.layout.item_schedule_tab);
    }

    private int flag = -1;
    public void setSel(int index){
        flag = index;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, TabOneScheduleBean.DataDTO dataDTO) {

        String[] s = dataDTO.getDate().split("-");
        baseViewHolder.setText(R.id.day,s[2]);

        if (dataDTO.getDate().equals(ValidateUtils.getCurDate())){
            baseViewHolder.setText(R.id.week, "今天");
        }else {
            baseViewHolder.setText(R.id.week, AppConfig.obtainWeek(dataDTO.getDate(),"yyyy-MM-dd"));
        }


        if (getItemPosition(dataDTO) == flag){
            baseViewHolder.setBackgroundResource(R.id.item,R.drawable.rect_main_8);
            baseViewHolder.setTextColorRes(R.id.week,R.color.white);
            baseViewHolder.setTextColorRes(R.id.day,R.color.white);
        }else {
            baseViewHolder.setBackgroundResource(R.id.item,R.drawable.rect_f6_8);
            baseViewHolder.setTextColorRes(R.id.week,R.color.text_c);
            baseViewHolder.setTextColorRes(R.id.day,R.color.text_c);
        }

    }
}
